/*
 * bsp_mempool.h
 *
 * Copyright (C) 2011 - Dr.NP
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @version bsp_mempool.h 1.0
 * @package libbspcore
 * @author Dr.NP <np@bsgroup.org>
 * @update 10/09/2011
 */

#ifndef BSP_MEMPOOL_H

#define BSP_MEMPOOL_H                           1

#include <sys/types.h>
// Definations
#define SLAB_LINK_INITIAL                       32
#define SLAB_SIZE_BASE                          64
#define SLAB_FREE_LIST_INITIAL                  1024
#define BLOCK_LIST_INITIAL                      256
#define BLOCK_SIZE                              16777216

// Macros

// Structs
struct slab_t
{
    int slab_id;
    int item_size;
    int item_curr_total;
    int item_capacity;
    size_t free_list_size;
    size_t free_list_data_size;
    void **free_list;
    size_t block_list_size;
    size_t block_list_data_size;
    void **block_list;
    struct slab_t *next;
    struct slab_t *prev;
};

// Functions
int mempool_init();
void * mempool_alloc(size_t);
void * mempool_realloc(void *, size_t);
int mempool_free(void *);

#endif  /* bsp_mempool.h */
